package com.neuedu.dao;

import com.neuedu.entity.UploadFile;
import com.neuedu.utils.DBUtils;

import java.util.List;

public class UploadFileDao {

    /**
     * 查询列表
     * @return
     */
    public List<UploadFile> selectList(){
        String sql = " select * from  upload_files ";
        return DBUtils.selectList(UploadFile.class,sql);
    }

    /**
     * 根据主键查询信息
     * @param id
     * @return
     */
    public UploadFile  getOne(Integer id){
        String sql = " select * from upload_files where id = ? ";
        return DBUtils.selectOne(UploadFile.class,sql,id);
    }


    /**
     * 保存信息
     * @param uploadFile
     * @return
     */
    public int insert(UploadFile uploadFile){
        String sql = "insert into upload_files( origin_name,  path, size, ip ) values(?,?,?,?) ";
        return DBUtils.update(sql,
                uploadFile.getOriginName(),
                uploadFile.getPath(),
                uploadFile.getSize(),
                uploadFile.getIp()
                );
    }
}